<?php

	require_once '../libs/functions.php';
/*	$conn = &ADONewConnection('mysqli');
	$conn->debug = false;
	$conn->Connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
 $conn->Execute("CALL bus_cqKbi(123519, 1, 50)");
$re = $conn->Execute("select @result");

if ($re){
		$uin = $re->fields['@result'];
}

//echo $uin;
var_dump($uin);*/
header("Content-Type:text/html;charset=UTF-8");
/*$str = "大师大师大师的道德法";

echo mb_strwidth($str, 'UTF8');
echo '<br />'.cut_str($str, 5, 0, 'UTF-8');
	
*/


$nick = "s大师大师的撒";
$sum = mb_strlen($nick, 'UTF-8');
if (  $sum> 5 ) {
			$nick = cut_str($nick, 5, 0, 'UTF-8');
		}
echo $sum.'<br />'.$nick;
		











/*

* 统计字符串长度
*@author langwan
*@param $str 被统计字符串

*/

function strlen_u($str, $charset) {

$n = 0; $p = 0; $c = '';
$len = strlen($str);
if($charset == 'UTF-8') {
for($i = 0; $i < $len; $i++) {
$c = ord($str{$i});
if($c > 252) {
$p = 5;
} elseif($c > 248) {
$p = 4;
} elseif($c > 240) {
$p = 3;
} elseif($c > 224) {
$p = 2;
} elseif($c > 192) {
$p = 1;
} else {
$p = 0;
}
$i+=$p;$n++;
}
} else {
for($i = 0; $i < $len; $i++) {
$c = ord($str{$i});
if($c > 127) {
$p = 1;
} else {
$p = 0;
}
$i+=$p;$n++;
}
}

return $n;
}





?>